<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <home></home>
  </div>
  <script src="./vue.js"></script>
  <script>
  
    // 创建子组件组件对象
    const Child2 = {
      inject: ['a', 'b'],
      template:`
        <div>
          <h3>子组件2</h3>  
          {{ msg }}
        </div>
      `,
      data(){
        return {
          msg: '子组件2的数据'
        }
      },
      mounted(){
        console.log(this, 333);
      }
    }
    // 定义父组件
    const Home = {
      provide:{
        a: '我是a数据',
        b: '我是b数据'
      },
      template: `
        <div>
          <h2>父组件</h2>  
          
          <hr/>
          <child2></child2>
        </div>
      `,
      data(){
        return {
          msg:'父组件数据'
        }
      },
      components: {
        Child2
      }
    }
    
    Vue.component('Home', Home);
    const vm = new Vue({
      // vm功能将vue语法渲染到 视图
      el: '#app'
    })
  </script>
</body>
</html>